Skip to content

unify(common): Merge Registry code#2193

Merged
xezon merged 1 commit intoTheSuperHackers:mainfrom
xezon:xezon/unify-registry
Jan 27, 2026
Merged

unify(common): Merge Registry code#2193
xezon merged 1 commit intoTheSuperHackers:mainfrom
xezon:xezon/unify-registry

Conversation

@xezon
Copy link

@xezon xezon commented Jan 26, 2026

This change merges the Registry code in GameEngine.

@xezon xezon added this to the Code foundation build up milestone Jan 26, 2026
@xezon xezon added Gen Relates to Generals ZH Relates to Zero Hour Unify Unifies code between Generals and Zero Hour labels Jan 26, 2026
@greptile-apps
Copy link

greptile-apps bot commented Jan 26, 2026

Greptile Overview

Greptile Summary

This PR successfully unifies the Registry code between Generals and Zero Hour by introducing RTS_GENERALS and RTS_ZEROHOUR preprocessor directives to differentiate registry paths at compile time.

Key Changes:

  • Added GetStringFromGeneralsRegistry() function to allow Zero Hour code to explicitly access the original Generals registry path
  • Modified GetStringFromRegistry() and GetUnsignedIntFromRegistry() to use conditional compilation for selecting the correct registry path based on game version
  • Both Generals and GeneralsMD implementations now share unified code structure with only the registry paths differing based on preprocessor macros
  • Added clarifying comment about static memory leak in GetRegistryLanguage() that was already present

The implementation correctly follows the codebase's unification pattern and maintains backward compatibility while enabling code sharing between game versions.

Confidence Score: 5/5

  • This PR is safe to merge with no issues found
  • The changes are straightforward code unification using preprocessor directives, maintain existing functionality, and follow established patterns in the codebase. No logic errors, security issues, or breaking changes introduced.
  • No files require special attention

Important Files Changed

Filename Overview
Generals/Code/GameEngine/Include/Common/Registry.h Added declaration for GetStringFromGeneralsRegistry function to support cross-version registry access
Generals/Code/GameEngine/Source/Common/System/registry.cpp Unified registry code with RTS_GENERALS/RTS_ZEROHOUR preprocessor directives and added GetStringFromGeneralsRegistry implementation
GeneralsMD/Code/GameEngine/Source/Common/System/registry.cpp Added RTS_GENERALS/RTS_ZEROHOUR preprocessor directives to unify registry path handling across game versions

Sequence Diagram

sequenceDiagram
    participant App as Application Code
    participant API as Registry API
    participant Helper as Helper Functions
    participant WinReg as Windows Registry

    Note over App,WinReg: Registry Read Flow

    App->>API: GetStringFromRegistry(path, key, val)
    API->>API: Determine registry path based on RTS_GENERALS/RTS_ZEROHOUR
    API->>Helper: getStringFromRegistry(HKEY_LOCAL_MACHINE, fullPath, key, val)
    Helper->>WinReg: RegOpenKeyEx(HKEY_LOCAL_MACHINE, ...)
    alt Key Found
        Helper->>WinReg: RegQueryValueEx(...)
        WinReg-->>Helper: Return value
        Helper-->>API: Return TRUE
        API-->>App: Return TRUE with value
    else Key Not Found
        Helper-->>API: Return FALSE
        API->>Helper: getStringFromRegistry(HKEY_CURRENT_USER, fullPath, key, val)
        Helper->>WinReg: RegOpenKeyEx(HKEY_CURRENT_USER, ...)
        alt Key Found
            Helper->>WinReg: RegQueryValueEx(...)
            WinReg-->>Helper: Return value
            Helper-->>API: Return TRUE
            API-->>App: Return TRUE with value
        else Key Not Found
            Helper-->>API: Return FALSE
            API-->>App: Return FALSE
        end
    end

    Note over App,WinReg: Cross-Version Access

    App->>API: GetStringFromGeneralsRegistry(path, key, val)
    Note over API: Always uses Generals registry path
    API->>Helper: getStringFromRegistry(HKEY_LOCAL_MACHINE, "...\\Generals"+path, key, val)
    Helper->>WinReg: RegOpenKeyEx(...)
    alt Key Found in HKLM
        WinReg-->>Helper: Return value
        Helper-->>API: Return TRUE
        API-->>App: Return TRUE with value
    else Try HKCU
        API->>Helper: getStringFromRegistry(HKEY_CURRENT_USER, "...\\Generals"+path, key, val)
        Helper->>WinReg: RegOpenKeyEx(...)
        WinReg-->>Helper: Return value or error
        Helper-->>API: Return TRUE/FALSE
        API-->>App: Return TRUE/FALSE
    end
Loading

@xezon xezon force-pushed the xezon/unify-registry branch from 2433256 to c951a59 Compare January 27, 2026 20:58
Copy link

@Skyaero42 Skyaero42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@xezon xezon merged commit f15abf3 into TheSuperHackers:main Jan 27, 2026
24 checks passed
@xezon xezon deleted the xezon/unify-registry branch January 27, 2026 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Gen Relates to Generals Unify Unifies code between Generals and Zero Hour ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants